# gao.pm
package gao;

sub scanl($&@) {
	my ($s, $f, @a) = @_;
	my @retval = ($s);
	for (@a) {
		push @retval, $s = &$f($s, $_);
	}
	return @retval;
}

unless (defined caller) {
	print join(', ', scanl(1, sub{@_[0] * @_[1]}, (1 .. 10))), "\n";
} else {
	print "imported by ", scalar caller, "\n";
}
#> 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800
